package restaurant.iterators;

import java.util.ArrayList;


/**
 * A standard iterator over a collection.
 * 
 * @author Odessa
 */

public class StandardIterator implements Iterator
{
	/** The index into the ArrayList. */
	private int index = 0;

	/** The list of objects. */
	private ArrayList<Object> list;



	/**
	 * Instantiates a new standard iterator.
	 * 
	 * @param list the list of items in the collection.
	 */
	public StandardIterator(ArrayList<Object> list) {
		this.list = list;
	}



	/**
	 * Determines if there is another element in the collection.
	 * 
	 * @return {@code true} if there are more items on the collection.
	 * @see restaurant.iterators.Iterator#hasNext()
	 */
	@Override
	public boolean hasNext()
	{
		if (index < list.size())
			return true;
		else
			return false;
	}



	/**
	 * Returns the next element in the collection.
	 * 
	 * @return the next element in the collection.
	 * @see restaurant.iterators.Iterator#next()
	 */
	@Override
	public Object next()
	{
		if (this.hasNext())
			return list.get(index++);
		else
			return null;
	}

}
